(ns liberator-sample.core.documentation.execution-model
  (:require [liberator.core :refer [defresource resource]]
            [liberator.dev :refer [wrap-trace]]
            [compojure.core :refer [defroutes ANY]]
            [ring.middleware.params :refer [wrap-params]]
            [org.httpkit.server :as server]
            [clojure.java.io :as io]
            [clojure.data.json :as json])
  (:use clojure.pprint))

(defn lookup-entity []
  {:a 1})

;; Context
(declare foo)
(defresource foo
             :exists? (fn [ctx] (if-let [x (lookup-entity)]
                                  {:entity x}))
             :handle-ok :entity)

(defresource foo
             :service-available? {:a [1]}
             :exists? (fn [ctx] #(assoc ctx :a [2]))
             :handle-ok :entity)